<template>
  <a-select
    :placeholder="$t('pleaseSelect')"
    :allow-clean="true"
    :disabled="disabled"
    v-model="selectedValue"
  >
    <a-select-option v-for="item in options" :key="item.id" :value="item.id">
      {{ $t(item.name) }}
    </a-select-option>
  </a-select>
</template>
<script>
export default {
  props: {
    defaultValue: {
      type: String,
      default () {
        return '1'
      }
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      selectedValue: '1',
      options: [{
        id: '1',
        name: 'yes'
      }, {
        id: '0',
        name: 'no'
      }]
    }
  },
  watch: {
    defaultValue: {
      handler (val) {
        if (val !== this.selectedValue) {
          this.selectedValue = this.defaultValue
        }
      },
      immediate: true
    },
    selectedValue (val) {
      if (val === this.defaultValue) {
        return
      }
      this.$emit('changeoption', val)
    }
  },
  created () {
  },
  methods: {
  }
}
</script>
